package interfaces;

import dao.SuspeitoDAO;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import modelo.Suspeito;

/**
 *
 * @author marcieli
 */
public class FrameSuspeitoGerencia extends javax.swing.JInternalFrame {

    List<Suspeito> lista = new ArrayList<Suspeito>();
    Integer contCodigo = 0;
    Integer posicaolista;

    public FrameSuspeitoGerencia() {
        initComponents();
        lista = sp.Listar();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        Traços = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtNome = new javax.swing.JTextField();
        txtOutros = new javax.swing.JTextField();
        ComboSexo = new javax.swing.JComboBox();
        ComboOcupacao = new javax.swing.JComboBox();
        ComboEsporte = new javax.swing.JComboBox();
        ComboCabelo = new javax.swing.JComboBox();
        ComboCarro = new javax.swing.JComboBox();
        ComboTraco = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        txtCod = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        ButNovo1 = new javax.swing.JButton();
        ButAtualizar1 = new javax.swing.JButton();
        ButInserir1 = new javax.swing.JButton();
        ButRemover1 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        ButPrimeiro2 = new javax.swing.JButton();
        ButAnterior2 = new javax.swing.JButton();
        ButProximo2 = new javax.swing.JButton();
        ButUltimo2 = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("Gerenciar suspeitos");

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel1.setText("Imagem");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(82, 82, 82)
                .addComponent(jLabel1)
                .addContainerGap(98, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(73, 73, 73)
                .addComponent(jLabel1)
                .addContainerGap(157, Short.MAX_VALUE))
        );

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Nome:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("Ocupação:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel3.setText("Sexo:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Esporte:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel6.setText("Cabelo:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Carro:");

        Traços.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        Traços.setText("Traços:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Outros:");

        ComboSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Feminino", "Masculino" }));

        ComboOcupacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Atendente do McDonalds", "Advogado(a)", "Empresario(a)", "Professor(a) de dança", "Professor(a)", "Cozinheiro(a)" }));

        ComboEsporte.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Volei", "Futebol", "Basquete", "Alpinismo", "Peteca", "Surf" }));

        ComboCabelo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Loiro", "Ruivo", "Castanho", "Preto" }));

        ComboCarro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Camaro", "Fusca", "Belina", "Motocicleta", "Corcel", "Fusion" }));
        ComboCarro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboCarroActionPerformed(evt);
            }
        });

        ComboTraco.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tatuagem", "Cicatriz", "Machucado", "Manco", "Anel" }));

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel12.setText("Código:");

        txtCod.setEditable(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtOutros))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNome)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(txtCod, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(ComboEsporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(18, 18, 18)
                                .addComponent(ComboCabelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(18, 18, 18)
                                .addComponent(ComboCarro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(Traços)
                                .addGap(18, 18, 18)
                                .addComponent(ComboTraco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(ComboOcupacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(ComboSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 278, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(3, 3, 3)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(txtCod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(ComboSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel4))
                    .addComponent(ComboOcupacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(ComboEsporte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(ComboCabelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(ComboCarro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Traços)
                    .addComponent(ComboTraco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(txtOutros, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE))
                .addGap(4, 4, 4))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções"));

        ButNovo1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButNovo1.setText("Novo");
        ButNovo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButNovo1ActionPerformed(evt);
            }
        });

        ButAtualizar1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButAtualizar1.setText("Atualizar");
        ButAtualizar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButAtualizar1ActionPerformed(evt);
            }
        });

        ButInserir1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButInserir1.setText("Inserir");
        ButInserir1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButInserir1ActionPerformed(evt);
            }
        });

        ButRemover1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButRemover1.setText("Excluir");
        ButRemover1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButRemover1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButInserir1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButAtualizar1)
                .addGap(18, 18, 18)
                .addComponent(ButNovo1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(ButRemover1, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButInserir1)
                    .addComponent(ButAtualizar1)
                    .addComponent(ButNovo1)
                    .addComponent(ButRemover1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Navegação"));

        ButPrimeiro2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButPrimeiro2.setText("Primeiro");
        ButPrimeiro2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButPrimeiro2ActionPerformed(evt);
            }
        });

        ButAnterior2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButAnterior2.setText("Anterior");
        ButAnterior2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButAnterior2ActionPerformed(evt);
            }
        });

        ButProximo2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButProximo2.setText("Proximo");
        ButProximo2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButProximo2ActionPerformed(evt);
            }
        });

        ButUltimo2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButUltimo2.setText("Ultimo");
        ButUltimo2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButUltimo2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButPrimeiro2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(ButAnterior2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(ButProximo2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(ButUltimo2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButPrimeiro2)
                    .addComponent(ButAnterior2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ButProximo2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ButUltimo2))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(53, 53, 53)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(194, 194, 194)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ComboCarroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboCarroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ComboCarroActionPerformed

    private void ButNovo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButNovo1ActionPerformed
        LimparDados();
    }//GEN-LAST:event_ButNovo1ActionPerformed

    private void ButAtualizar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButAtualizar1ActionPerformed
//        if (txtNome.getText().equals("") || ComboSexo.getSelectedItem().equals("")
//                || ComboOcupacao.getSelectedItem().equals("") || ComboEsporte.getSelectedItem().equals("")
//                || ComboCabelo.getSelectedItem().equals("") || ComboCarro.getSelectedItem().equals("")
//                || ComboTraco.getSelectedItem().equals("") || txtOutros.getText().equals("")) {
//            JOptionPane.showMessageDialog(null, "Todos os campos são obrigatórios");
//        } else {
//
//            Integer codigo = Integer.parseInt(txtCod.getText());
//            for (Suspeito s : lista) {
//                if (codigo == s.getCodigo()) {
//
//                    s.setNome(txtNome.getText());
//                    s.setSexo(ComboSexo.getSelectedItem().toString());
//                    s.setOcupacao(ComboOcupacao.getSelectedItem().toString());
//                    s.setEsporte(ComboEsporte.getSelectedItem().toString());
//                    s.setCabelo(ComboCabelo.getSelectedItem().toString());
//                    s.setCarro(ComboCarro.getSelectedItem().toString());
//                    s.setTracos(ComboTraco.getSelectedItem().toString());
//                    s.setOutros(txtOutros.getText());
//                    break;
//                }
//            }
//            JOptionPane.showMessageDialog(null, "Suspeito atualizado com sucesso");
//            LimparDados();
//
//        }
    }//GEN-LAST:event_ButAtualizar1ActionPerformed

    private void ButInserir1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButInserir1ActionPerformed
        if (txtNome.getText().equals("") || ComboSexo.getSelectedItem().equals("")
                || ComboOcupacao.getSelectedItem().equals("") || ComboEsporte.getSelectedItem().equals("")
                || ComboCabelo.getSelectedItem().equals("") || ComboCarro.getSelectedItem().equals("")
                || ComboTraco.getSelectedItem().equals("") || txtOutros.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Todos os campos são obrigatórios");

        } else {

            sp.Cadastrar(CarregaDados());
            JOptionPane.showMessageDialog(null, "Suspeito inserido com sucesso");
            LimparDados();
            lista = sp.Listar();
        }
    }//GEN-LAST:event_ButInserir1ActionPerformed

    private void ButPrimeiro2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButPrimeiro2ActionPerformed

        Suspeito s = lista.get(0);
        txtCod.setText(s.getCodigo().toString());
        txtNome.setText(s.getNome());
        ComboSexo.setSelectedItem(s.getSexo());
        ComboOcupacao.setSelectedItem(s.getOcupacao());
        ComboEsporte.setSelectedItem(s.getEsporte());
        ComboCabelo.setSelectedItem(s.getCabelo());
        ComboCarro.setSelectedItem(s.getCarro());
        ComboTraco.setSelectedItem(s.getTracos());
        txtOutros.setText(s.getOutros());

        posicaolista = 0;
    }//GEN-LAST:event_ButPrimeiro2ActionPerformed

    private void ButAnterior2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButAnterior2ActionPerformed
        if (posicaolista > 0) {
            posicaolista = posicaolista - 1;
            Suspeito s = lista.get(posicaolista);

            txtCod.setText(s.getCodigo().toString());
            txtNome.setText(s.getNome());
            ComboSexo.setSelectedItem(s.getSexo());
            ComboOcupacao.setSelectedItem(s.getOcupacao());
            ComboEsporte.setSelectedItem(s.getEsporte());
            ComboCabelo.setSelectedItem(s.getCabelo());
            ComboCarro.setSelectedItem(s.getCarro());
            ComboTraco.setSelectedItem(s.getTracos());
            txtOutros.setText(s.getOutros());

            posicaolista = lista.size() - 1;
        }
    }//GEN-LAST:event_ButAnterior2ActionPerformed

    private void ButProximo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButProximo2ActionPerformed

        if (posicaolista < (lista.size() - 1)) {
            posicaolista = posicaolista + 1;
            Suspeito s = lista.get(posicaolista);
            txtCod.setText(s.getCodigo().toString());
            txtNome.setText(s.getNome());
            ComboSexo.setSelectedItem(s.getSexo());
            ComboOcupacao.setSelectedItem(s.getOcupacao());
            ComboEsporte.setSelectedItem(s.getEsporte());
            ComboCabelo.setSelectedItem(s.getCabelo());
            ComboCarro.setSelectedItem(s.getCarro());
            ComboTraco.setSelectedItem(s.getTracos());
            txtOutros.setText(s.getOutros());
            posicaolista = lista.size() - 1;
        }
    }//GEN-LAST:event_ButProximo2ActionPerformed

    private void ButUltimo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButUltimo2ActionPerformed
        Suspeito s = lista.get((lista.size() - 1));
        txtCod.setText(s.getCodigo().toString());

        txtNome.setText(s.getNome());
        ComboSexo.setSelectedItem(s.getSexo());
        ComboOcupacao.setSelectedItem(s.getOcupacao());
        ComboEsporte.setSelectedItem(s.getEsporte());
        ComboCabelo.setSelectedItem(s.getCabelo());
        ComboCarro.setSelectedItem(s.getCarro());
        ComboTraco.setSelectedItem(s.getTracos());
        txtOutros.setText(s.getOutros());
        posicaolista = lista.size() - 1;
    }//GEN-LAST:event_ButUltimo2ActionPerformed

    private void ButRemover1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButRemover1ActionPerformed
        int confirma = JOptionPane.showConfirmDialog(null, "Deseja excluir?");
        if (confirma == 0) {
            s.setCodigo(Integer.parseInt(txtCod.getText()));
            sp.Excluir(s);
            LimparDados();
            lista = sp.Listar();

        }
    }//GEN-LAST:event_ButRemover1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButAnterior2;
    private javax.swing.JButton ButAtualizar1;
    private javax.swing.JButton ButInserir1;
    private javax.swing.JButton ButNovo1;
    private javax.swing.JButton ButPrimeiro2;
    private javax.swing.JButton ButProximo2;
    private javax.swing.JButton ButRemover1;
    private javax.swing.JButton ButUltimo2;
    private javax.swing.JComboBox ComboCabelo;
    private javax.swing.JComboBox ComboCarro;
    private javax.swing.JComboBox ComboEsporte;
    private javax.swing.JComboBox ComboOcupacao;
    private javax.swing.JComboBox ComboSexo;
    private javax.swing.JComboBox ComboTraco;
    private javax.swing.JLabel Traços;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JTextField txtCod;
    private javax.swing.JTextField txtNome;
    private javax.swing.JTextField txtOutros;
    // End of variables declaration//GEN-END:variables

    SuspeitoDAO sp = new SuspeitoDAO();
    Suspeito s = new Suspeito();

    public Suspeito CarregaDados() {

        s.setNome(txtNome.getText());
        s.setCabelo(ComboCabelo.getSelectedItem().toString());
        s.setCarro(ComboCarro.getSelectedItem().toString());
        s.setEsporte(ComboEsporte.getSelectedItem().toString());
        s.setOutros(txtOutros.getText());
        s.setOcupacao(ComboOcupacao.getSelectedItem().toString());
        s.setTracos(ComboTraco.getSelectedItem().toString());
        s.setSexo(ComboSexo.getSelectedItem().toString());

        return s;
    }

    public void LimparDados() {
        txtCod.setText(null);
        txtNome.setText(null);

        ComboSexo.setSelectedItem(null);
        ComboOcupacao.setSelectedItem(null);
        ComboEsporte.setSelectedItem(null);
        ComboCabelo.setSelectedItem(null);
        ComboCarro.setSelectedItem(null);
        ComboTraco.setSelectedItem(null);
        txtOutros.setText(null);
    }
}
